<?php

namespace app\serversetting\service\setting;
use app\manage\service\ApiBase;

/**
 * @author:      李颖
 * @DateTime:    2017-07-10 11:33:35
 * @Description: 全局设置
 */

class Setting extends ApiBase
{

	protected $settingLogic = 'app\serversetting\logic\Setting';
    protected $settingValidate = 'app\serversetting\validate\Setting';

    use \app\serveruser\traits\AddAppIdToRunOne;

    /*添加一个配置*/
    public function addSet(): array
    {
    	$data = $this->receiveData(['category_id'=>0,'name'=>' ','value'=>'','action'=>' ','type'=>0,'order'=>100,'other_info'=>[],'token'=>' ']);
        if(is_string($data['other_info'])){
            $data['other_info'] = json_decode($data['other_info'], true);
        }
        return $this->_addAppIdToRunOne($data, 'serversetting/setting/Setting/addSet', $this->settingValidate, $this->settingLogic, false, 'addSet');
    }

    /*编辑一个配置*/
    public function editSet(): array
    {
    	$data = $this->issetReceiveData(['id'=>0,'category_id'=>0,'name'=>' ','value'=>' ','action'=>' ','type'=>0,'order'=>100,'other_info'=>[],'token'=>' ']);
        if(is_string($data['other_info'])){
            $data['other_info'] = json_decode($data['other_info'], true);
        }
        //value在不在other_info中在newthink中检验
        return $this->_addAppIdToRunOne($data, 'serversetting/setting/Setting/editSet', $this->settingValidate, $this->settingLogic, false, 'editSet');
    }

    /*获取某个具体配置*/
    public function getOneSet(): array
    {
    	$data = $this->receiveData(['id'=>0,'token'=>' ']);
        return $this->_addAppIdToRunOne($data, 'serversetting/setting/Setting/getOneSet', $this->settingValidate, $this->settingLogic, false, 'getOneSet');
    }

    /*获取本应用配置列表*/
    public function getAppSet(): array
    {
    	$data = $this->receiveData(['page'=>1,'listRows'=>15,'token'=>' ']);
        return $this->stepRun($data, 'serversetting/setting/Setting/getAppSet', 'getAppSet', 'getAppSet');
    }





}






